darkBackground Examples

Base code from Elsa Birch's darkBackground.m function on MATLAB file exchange.
https://www.mathworks.com/matlabcentral/fileexchange/30222-quick-dark-or-custom-plot-background
Examples taken from respective MATLAB help pages.
Table of Contents
clear; clc;
cd('/Users/duncan/Documents/GitHub/darkBackground_matlab')

no inputs

clear;
figure();
x = linspace(0,2*pi,100);
plot(x, cos(x), 'linewidth', 2, 'displayname', 'cos')
legend('location', 'best')
darkBackground()

specify figure handle

clear;
fig = figure();
x = linspace(0,2*pi,100);
plot(x, cos(x), 'linewidth', 2, 'displayname', 'cos')
legend('location', 'best')
darkBackground('hFigure', fig)

specify background color

clear;
figure();
x = linspace(0,2*pi,100);
plot(x, cos(x), 'linewidth', 2, 'DisplayName','cos')
legend('location', 'best')
darkBackground("backColor", [0.3, 0.3, 0.3]); % gray background

specify foreground color

clear;
figure();
x = linspace(0,2*pi,100);
plot(x, cos(x), 'linewidth', 2, 'DisplayName','cos')
legend('location', 'best')
darkBackground("foreColor", [1, 0, 0]); % red foreground

Line Plots

clear;

plot

https://www.mathworks.com/help/matlab/ref/plot.html
figure();
x = 0:pi/100:2*pi;
y = sin(x);
plot(x,y, 'linewidth', 2);
darkBackground()

plot3

https://www.mathworks.com/help/matlab/ref/plot3.html
figure();
t = 0:pi/50:10*pi;
st = sin(t);
ct = cos(t);
plot3(st,ct,t, 'linewidth', 2);
darkBackground()

stairs

https://www.mathworks.com/help/matlab/ref/stairs.html
X = linspace(0,4*pi,40);
Y = sin(X);
figure();
stairs(Y, 'linewidth', 2);
darkBackground()

errorbar

https://www.mathworks.com/help/matlab/ref/errorbar.html
figure();
x = 1:10:100;
y = [20 30 45 40 60 65 80 75 95 90];
err = 8*ones(size(y));
errorbar(x,y,err, 'linewidth', 2);
darkBackground()

area

https://www.mathworks.com/help/matlab/ref/area.html
figure();
y = [1 5 6 3];
area(y)
darkBackground()

stackedplot

https://www.mathworks.com/help/matlab/ref/stackedplot.html
tbl = readtimetable("outages.csv","TextType","string");
head(tbl,5);
tbl = sortrows(tbl);
head(tbl,5);
figure();
stackedplot(tbl, 'linewidth', 2); % does not editable properties to give correct look. I recommend just using subplot or tiledlayout instead.
darkBackground();

loglog

https://www.mathworks.com/help/matlab/ref/loglog.html
figure();
x = logspace(-1,2);
y = 2.^x;
loglog(x,y, 'linewidth', 2);
grid on
set(gca, 'linewidth', 2); % make grid stand out more
darkBackground()

semilogx

https://www.mathworks.com/help/matlab/ref/semilogx.html
figure();
x = logspace(-1,2);
y = x;
semilogx(x,y, 'linewidth', 2);
grid on
darkBackground()

semilogy

https://www.mathworks.com/help/matlab/ref/semilogy.html
figure();
x = 1:100;
y = x.^2;
semilogy(x,y, 'linewidth', 2);
grid on
darkBackground()

fplot

https://www.mathworks.com/help/matlab/ref/fplot.html
figure()
fplot(@(x) sin(x), 'linewidth', 2);
darkBackground()

fplot3

https://www.mathworks.com/help/matlab/ref/fplot3.html
figure();
xt = @(t) sin(t);
yt = @(t) cos(t);
zt = @(t) t;
fplot3(xt,yt,zt, 'linewidth', 2);
darkBackground()

fimplict

https://www.mathworks.com/help/matlab/ref/fimplicit.html
figure();
fimplicit(@(x,y) x.^2 - y.^2 - 1, 'linewidth', 2);
darkBackground()

Scatter and Bubble Charts

clear;

scatter

https://www.mathworks.com/help/matlab/ref/scatter.html#btrli6f-1
figure();
x = linspace(0,3*pi,200);
y = cos(x) + rand(1,200);
scatter(x,y, 30, [0,0,1], 'filled')
darkBackground()

scatter3

https://www.mathworks.com/help/matlab/ref/scatter3.html#btrui18-82
figure();
[X,Y,Z] = sphere(16);
x = [0.5*X(:); 0.75*X(:); X(:)];
y = [0.5*Y(:); 0.75*Y(:); Y(:)];
z = [0.5*Z(:); 0.75*Z(:); Z(:)];
scatter3(x,y,z, 30, [0,0,1], 'filled')
darkBackground()

bubblechart

https://www.mathworks.com/help/matlab/ref/bubblechart.html#mw_4c9c2ee2-e7a8-4530-92d9-84d6fd795280
figure();
x = 1:20;
y = rand(1,20);
sz = rand(1,20);
bubblechart(x,y,sz);
darkBackground()

bubblechart3

https://www.mathworks.com/help/matlab/ref/bubblechart3.html#mw_969a4ce8-00e6-41e5-b39a-7fc0136e0506
figure();
x = rand(1,20);
y = rand(1,20);
z = rand(1,20);
sz = rand(1,20);
bubblechart3(x,y,z,sz);
darkBackground()

swarmchart

https://www.mathworks.com/help/matlab/ref/swarmchart.html#mw_d8611753-8109-4ac3-ba02-32ed933eb186
figure();
x = [ones(1,500) 2*ones(1,500) 3*ones(1,500)];
y1 = 2 * randn(1,500);
y2 = 3 * randn(1,500) + 5;
y3 = 5 * randn(1,500) + 5;
y = [y1 y2 y3];
swarmchart(x,y)
darkBackground()

swarmchar3

https://www.mathworks.com/help/matlab/ref/swarmchart3.html#mw_3d563e6c-8720-4108-b94e-65f2d0e5d8d7
figure();
tbl = readtable(fullfile(matlabroot,'examples','matlab','data','BicycleCounts.csv'));
tbl(1:5,:);
daynames = ["Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday"];
x = categorical(tbl.Day,daynames);
ispm = tbl.Timestamp.Hour < 12;
y = categorical;
y(ispm) = "pm";
y(~ispm) = "am";
z= tbl.Eastbound;
swarmchart3(x,y,z);
darkBackground()

spy

https://www.mathworks.com/help/matlab/ref/spy.html#mw_32177bc4-0604-4dcf-a944-7f0622eeca64
figure();
B = bucky;
spy(B)
darkBackground()

Data Distribution Plots

clear;

histogram

https://www.mathworks.com/help/matlab/ref/matlab.graphics.chart.primitive.histogram.html#buhzm_z-7
figure();
x = randn(10000,1);
h = histogram(x);
darkBackground()

histogram2

https://www.mathworks.com/help/matlab/ref/matlab.graphics.chart.primitive.histogram2.html#buvi4ht-2
figure();
x = randn(10000,1);
y = randn(10000,1);
h = histogram2(x,y);
xlabel('x')
ylabel('y')
darkBackground()

pie

https://www.mathworks.com/help/matlab/ref/pie.html#buiol_j-9
figure();
X = [1 3 0.5 2.5 2];
pie(X)
darkBackground()

pie3

https://www.mathworks.com/help/matlab/ref/pie3.html
x = [1,3,0.5,2.5,2];
figure();
pie3(x)
darkBackground()

scatterhistogram

https://www.mathworks.com/help/matlab/ref/scatterhistogram.html#mw_4412e2fe-a2b0-4375-9a5f-f0dde5863366
load patients
tbl = table(LastName,Age,Gender,Height,Weight);
figure();
s = scatterhistogram(tbl,'Height','Weight');
darkBackground();

wordcloud

https://www.mathworks.com/help/matlab/ref/wordcloud.html#mw_4a150c4e-db54-4c09-b4ac-b09f8368ffdd
% not worth the battle
% figure();
% load sonnetsTable
%
% numWords = size(tbl,1);
% colors = rand(numWords,3);
% wordcloud(tbl,'Word','Count','Color',colors);
% title("Sonnets Word Cloud")
%
% darkBackground()

bubblecloud

https://www.mathworks.com/help/matlab/ref/bubblecloud.html#mw_543c69da-2e45-4448-91de-2ac86938c0f5
% not found in matlab
% figure();
% n = [58 115 81 252 180 124 40 80 50 20]';
% loc = ["NJ" "NY" "MA" "OH" "NH" "ME" "CT" "PA" "RI" "VT"]';
% plant = ["Plant A" "Plant A" "Plant A" "Plant A" ...
% "Plant A" "Plant A" "Plant A" "Plant B" "Plant B" "Plant B"]';
% tbl = table(n,loc,plant,'VariableNames',["Mislabeled" "State" "Manufacturing Plant"]);
%
% bubblecloud(tbl,"Mislabeled","State")
%
% bubblecloud(tbl,"Mislabeled","State","Manufacturing Plant")
%
% darkBackground()

heatmap

https://www.mathworks.com/help/matlab/ref/heatmap.html#bvlbhnq-1
figure();
load patients
tbl = table(LastName,Age,Gender,SelfAssessedHealthStatus,...
Smoker,Weight,Location);
h = heatmap(tbl,'Smoker','SelfAssessedHealthStatus');
darkBackground()

parallelplot

https://www.mathworks.com/help/matlab/ref/parallelplot.html#mw_e16c7b2e-cfba-4a73-9f90-cd346fbb4f2d
load patients
tbl = table(Diastolic,Smoker,Systolic);
figure();
p = parallelplot(tbl);
darkBackground();

plotmatrix

https://www.mathworks.com/help/matlab/ref/plotmatrix.html#btrxume-2
figure();
X = randn(50,3);
Y = reshape(1:150,50,3);
plotmatrix(X,Y);
darkBackground()

Discrete Data Plots

clear;

bar

https://www.mathworks.com/help/matlab/ref/bar.html#bthxcel
figure();
y = [75 91 105 123.5 131 150 179 203 226 249 281.5];
bar(y)
darkBackground()

barh

https://www.mathworks.com/help/matlab/ref/barh.html#mw_221f84b5-1c94-4025-ad84-a93600ec6774
figure();
y = [10 20 30 41];
barh(y)
darkBackground()

bar3

https://www.mathworks.com/help/matlab/ref/bar3.html
load count.dat
Z = count(1:10,:);
figure();
bar3(Z)
title('Detached Style')
darkBackground()

bar3h

https://www.mathworks.com/help/matlab/ref/bar3h.html
load count.dat
Y = count(1:10,:);
figure();
bar3h(Y)
darkBackground()

pareto

https://www.mathworks.com/help/matlab/ref/pareto.html#mw_9b599d2c-487d-4c10-89d9-1935cfc3bcf6
figure();
y = [2 3 45 20 32];
p = pareto(y);
p(2).LineWidth = 2;
darkBackground()

stem

https://www.mathworks.com/help/matlab/ref/stem.html#btrw_xi-87
figure();
Y = linspace(-2*pi,2*pi,50);
stem(Y, 'linewidth', 2);
darkBackground()

stem3

https://www.mathworks.com/help/matlab/ref/stem3.html#btrijff-1
figure();
X = linspace(-pi/2,pi/2,40);
Z = cos(X);
stem3(Z, 'linewidth', 2);
darkBackground()

Geographic Plots

clear;

geoplot

https://www.mathworks.com/help/matlab/ref/geoplot.html#mw_5da29e5a-1b0f-436b-8bc0-74b5daa7ddde
figure();
latSeattle = 47.62;
lonSeattle = -122.33;
latAnchorage = 61.20;
lonAnchorage = -149.9;
geoplot([latSeattle latAnchorage],[lonSeattle lonAnchorage],'g-*')
geolimits([45 62],[-149 -123])
darkBackground() % FIX

geoscatter

https://www.mathworks.com/help/matlab/ref/geoscatter.html#mw_eb7c9ae5-b33a-4d82-a629-477336722f76
figure();
lon = (-170:10:170);
lat = 50 * cosd(3*lon);
A = 101 + 100*(sind(2*lon));
C = cosd(4*lon);
geoscatter(lat,lon,A,C,'^')
darkBackground() % FIX

geobubble

https://www.mathworks.com/help/matlab/ref/geobubble.html#bvkoscj-7
figure();
tsunamis = readtable('tsunamis.xlsx');
geobubble(tsunamis.Latitude,tsunamis.Longitude,tsunamis.MaxHeight)
darkBackground() % FIX

Polar Plots

clear;

polarplot

https://www.mathworks.com/help/matlab/ref/polarplot.html#buyrszg-2
figure();
theta = 0:0.01:2*pi;
rho = sin(2*theta).*cos(2*theta);
polarplot(theta,rho)
darkBackground()

polarhistogram

https://www.mathworks.com/help/matlab/ref/polarhistogram.html#bvdhkhi-2_1
figure();
theta = [0.1 1.1 5.4 3.4 2.3 4.5 3.2 3.4 5.6 2.3 2.1 3.5 0.6 6.1];
polarhistogram(theta,6)
darkBackground()

polarscatter

https://www.mathworks.com/help/matlab/ref/polarscatter.html#bvdhjcv-2
figure();
th = pi/4:pi/4:2*pi;
r = [19 6 12 18 16 11 15 15];
polarscatter(th,r, 'filled')
darkBackground()

polarbubblechart

https://www.mathworks.com/help/matlab/ref/polarbubblechart.html#mw_2880ff74-40b6-4fbd-aa39-2edc4200a8b7
figure();
th = linspace(0,2*pi,10);
r = rand(1,10);
sz = rand(1,10);
polarbubblechart(th,r,sz);
darkBackground() % FIX

compass

https://www.mathworks.com/help/matlab/ref/compass.html#mw_4866ed21-10a7-4ccf-ac99-539c1fc84a31
figure();
u = [5 3 -4 -3 5];
v = [1 5 3 -2 -6];
c = compass(u,v);
for i = 1:length(c)
c(i).LineWidth = 2;
end
darkBackground('patchasBack', true) % FIX

ezpolar

https://www.mathworks.com/help/matlab/ref/ezpolar.html
figure();
ezp = ezpolar('1+cos(t)');
ezp.LineWidth = 2;
darkBackground('patchasBack', true) % FIX

Contour Plots

clear;

contour

https://www.mathworks.com/help/matlab/ref/contour.html#mw_4820d9ea-235f-49cb-ac16-850df44371c1
figure();
Z = peaks;
Z(:,26) = NaN;
[M,c] = contour(Z);
c.LineWidth = 2;
darkBackground()

contourf

https://www.mathworks.com/help/matlab/ref/contourf.html#mw_7e9cf324-8ed0-4c0a-bafa-150521bf2deb
figure();
Z = peaks;
contourf(Z)
darkBackground()

contour3

https://www.mathworks.com/help/matlab/ref/contour3.html#mw_ab156e8e-f186-4702-abc5-b6b6ab7f246f
figure();
[X,Y] = meshgrid(-5:0.25:5);
Z = X.^2 + Y.^2;
[M,c] = contour3(Z);
c.LineWidth = 2;
darkBackground()

contourslice

https://www.mathworks.com/help/matlab/ref/contourslice.html#mw_00357419-cf24-456b-8797-8537061572dc
figure();
[X,Y,Z,V] = flow;
zslice = 0;
c = contourslice(X,Y,Z,V,[],[],zslice);
for i = 1:length(c)
set(c(i), 'linewidth', 2);
end
grid on
darkBackground()

fcontour

https://www.mathworks.com/help/matlab/ref/fcontour.html#bu62qy6-10
figure();
f = @(x,y) sin(x) + cos(y);
fcontour(f, 'linewidth', 2)
darkBackground()

Vector Fields

clear;

quiver

https://www.mathworks.com/help/matlab/ref/quiver.html#mw_74092bc3-7377-437e-9b2e-b0ebda28e065
figure();
load('wind','x','y','u','v')
X = x(11:22,11:22,1);
Y = y(11:22,11:22,1);
U = u(11:22,11:22,1);
V = v(11:22,11:22,1);
quiver(X,Y,U,V, 'linewidth', 2);
axis equal
darkBackground()

quiver3

https://www.mathworks.com/help/matlab/ref/quiver3.html#mw_ba13de8c-2b4b-455d-8fb9-e8234b3ceb64
figure();
load wind
X = x(5:10,20:25,6:10);
Y = y(5:10,20:25,6:10);
Z = z(5:10,20:25,6:10);
U = u(5:10,20:25,6:10);
V = v(5:10,20:25,6:10);
W = w(5:10,20:25,6:10);
quiver3(X,Y,Z,U,V,W, 'linewidth', 2);
axis equal
darkBackground()

feather

https://www.mathworks.com/help/matlab/ref/feather.html#mw_e567362e-e972-449a-911b-02673d7dfb63
figure();
t = -pi/2:pi/8:pi/2;
u = 10*sin(t);
v = 10*cos(t);
f = feather(u,v);
for i = 1:length(f)
f(i).LineWidth = 2;
end
darkBackground()

Surface and Mesh Plots

clear;

surf

https://www.mathworks.com/help/matlab/ref/surf.html#bvgp3nn-2
figure();
[X,Y] = meshgrid(1:0.5:10,1:20);
Z = sin(X) + cos(Y);
surf(X,Y,Z)
darkBackground()

surfc

https://www.mathworks.com/help/matlab/ref/surfc.html#mw_8b53edac-0351-4b71-95d4-65e8a609c175
figure();
[X,Y] = meshgrid(1:0.5:10,1:20);
Z = sin(X) + cos(Y);
surfc(X,Y,Z)
darkBackground()

surfl

https://www.mathworks.com/help/matlab/ref/surfl.html#mw_c326f8ec-1540-4a03-89af-4544a3abe8db
figure();
[X,Y] = meshgrid(1:0.5:10,1:20);
Z = sin(X) + cos(Y);
surfl(X,Y,Z)
darkBackground()

ribbon

https://www.mathworks.com/help/matlab/ref/ribbon.html
[x,y] = meshgrid(-3:.5:3,-3:.1:3);
z = peaks(x,y);
figure();
ribbon(y,z)
darkBackground()

pcolor

https://www.mathworks.com/help/matlab/ref/pcolor.html
figure();
X = [1 2 3; 1 2 3; 1 2 3];
Y = X';
mymap = [1 0 0; 0 1 0; 0 0 1; 1 1 0; 0 0 0];
C = [3 4 5; 1 2 5; 5 5 5];
pcolor(X,Y,C)
colormap(mymap)
darkBackground()

fsurf

https://www.mathworks.com/help/matlab/ref/fsurf.html#bu62pyy-19
figure();
fsurf(@(x,y) sin(x)+cos(y))
darkBackground()

fimplicit3

https://www.mathworks.com/help/matlab/ref/fimplicit3.html#bvds9ev-2_1
figure();
fimplicit3(@(x,y,z) x.^2 + y.^2 - z.^2)
darkBackground()

mesh

https://www.mathworks.com/help/matlab/ref/mesh.html#mw_b7ae3e4b-e3ce-4535-a79a-ac08b8db3ee6
figure();
[X,Y] = meshgrid(-8:.5:8);
R = sqrt(X.^2 + Y.^2) + eps;
Z = sin(R)./R;
m = mesh(X,Y,Z);
m.LineWidth = 2;
darkBackground()

meshc

https://www.mathworks.com/help/matlab/ref/meshc.html#mw_85888d57-3dd9-4efc-8a14-ac7527431887
figure();
[X,Y] = meshgrid(-3:.125:3);
Z = peaks(X,Y);
m = meshc(X,Y,Z);
for i = 1:length(m)
m(i).LineWidth = 2;
end
darkBackground()

meshz

https://www.mathworks.com/help/matlab/ref/meshz.html#mw_f0d82b8d-b4c8-4f9c-8713-b01ca89d75cd
figure();
[X,Y] = meshgrid(-3:.125:3);
Z = peaks(X,Y);
m = meshz(X,Y,Z);
m.LineWidth = 2;
darkBackground()

waterfall

https://www.mathworks.com/help/matlab/ref/waterfall.html#mw_c5714771-7f6b-41a8-920d-e36d9404e57f
figure();
[X,Y] = meshgrid(-3:.125:3);
Z = peaks(X,Y);
waterfall(X,Y,Z)
darkBackground('patchasBack', true)

fmesh

https://www.mathworks.com/help/matlab/ref/fmesh.html#bu62qov-20
figure();
fmesh(@(x,y) sin(x)+cos(y))
darkBackground() % FIX ( in between color)

Volume Visualization

clear;

streamline

https://www.mathworks.com/help/matlab/ref/streamline.html#mw_8647cc3a-f5a2-410f-a6eb-d6135a383194
figure();
load wind
[startx,starty,startz] = meshgrid(80,20:10:50,0:5:15);
s = streamline(x,y,z,u,v,w,startx,starty,startz);
set(s, 'linewidth', 2);
axis tight
view(3);
darkBackground()

stremslice

https://www.mathworks.com/help/matlab/ref/streamslice.html#mw_a63828a7-a13a-4e84-8251-8d2c8fe0898a
figure();
load wind
s = streamslice(x,y,z,u,v,w,[],[],5);
for i = 1:length(s)
s(i).LineWidth = 2;
end
axis tight
darkBackground()

stremparticles

https://www.mathworks.com/help/matlab/ref/streamparticles.html
% figure();
% load wind
% figure
% daspect([1,1,1]);
% view(2)
% [verts,averts] = streamslice(x,y,z,u,v,w,[],[],5);
% sl = streamline([verts averts]);
% axis tight manual off;
% set(sl,'Visible','off')
% iverts = interpstreamspeed(x,y,z,u,v,w,verts,.05);
% zlim([4.9,5.1]);
% streamparticles(iverts, 200, ...
% 'Animate',15,'FrameRate',40, ...
% 'MarkerSize',10,'MarkerFaceColor',[0 .5 0])
%
% darkBackground()

streamribbon

https://www.mathworks.com/help/matlab/ref/streamribbon.html
figure();
load wind
[sx,sy,sz] = meshgrid(80,20:10:50,0:5:15);
streamribbon(x,y,z,u,v,w,sx,sy,sz);
axis tight
shading interp
view(3);
camlight
lighting gouraud
darkBackground()

streamtube

https://www.mathworks.com/help/matlab/ref/streamtube.html
figure();
load wind
[sx,sy,sz] = meshgrid(80,20:10:50,0:5:15);
streamtube(x,y,z,u,v,w,sx,sy,sz);
view(3);
axis tight
shading interp;
camlight;
lighting gouraud
darkBackground()

coneplot

https://www.mathworks.com/help/matlab/ref/coneplot.html
load wind
xmin = min(x(:));
xmax = max(x(:));
ymin = min(y(:));
ymax = max(y(:));
zmin = min(z(:));
xrange = linspace(xmin,xmax,8);
yrange = linspace(ymin,ymax,8);
zrange = 3:4:15;
[cx,cy,cz] = meshgrid(xrange,yrange,zrange);
figure();
hcone = coneplot(x,y,z,u,v,w,cx,cy,cz,5);
hcone.FaceColor = 'red';
hcone.EdgeColor = 'none';
darkBackground()

slice

https://www.mathworks.com/help/matlab/ref/slice.html#mw_dd58bff6-6022-437d-b8dd-dd00121d992c
figure();
[X,Y,Z] = meshgrid(-2:.2:2);
V = X.*exp(-X.^2-Y.^2-Z.^2);
xslice = [-1.2,0.8,2];
yslice = [];
zslice = 0;
slice(X,Y,Z,V,xslice,yslice,zslice)
darkBackground()

Animation

clear;

animatedline

https://www.mathworks.com/help/matlab/ref/animatedline.html#mw_d6046c3c-0566-47e0-90e0-3b5a777fc85b
figure();
h = animatedline;
set(h, 'linewidth', 2)
set(h, 'color', 'r')
axis([0,4*pi,-1,1])
darkBackground()
x = linspace(0,4*pi,100);
y = sin(x);
for k = 1:length(x)
addpoints(h,x(k),y(k));
drawnow
end

comet

https://www.mathworks.com/help/matlab/ref/comet.html#mw_00bb79c0-a384-41f0-bc8f-c16efdd9b4b3
figure();
t = 0:pi/50:2*pi;
y = sin(t);
x = cos(t);
comet(x,y)
darkBackground() % FIX

comet3

https://www.mathworks.com/help/matlab/ref/comet3.html#mw_52b691ab-f238-43cf-840c-ed021ee4e0fb
figure();
[xmat,ymat,zmat] = peaks(100);
xvec = xmat(:);
yvec = ymat(:);
zvec = zmat(:);
comet3(xvec,yvec,zvec)
darkBackground() % FIX

Images

clear;

image

https://www.mathworks.com/help/matlab/ref/image.html#buqlsdw-2
figure();
C = [0 2 4 6; 8 10 12 14; 16 18 20 22];
image(C)
colorbar
darkBackground()

imagesc

https://www.mathworks.com/help/matlab/ref/imagesc.html#bux1nif-2
figure();
C = [0 2 4 6; 8 10 12 14; 16 18 20 22];
imagesc(C)
colorbar
darkBackground()

Layouts

clear;

subplot

figure();
x = linspace(0,2*pi,100);
subplot(1,2,1)
plot(x, cos(x), 'linewidth', 2, 'DisplayName','cos')
legend('location', 'best')
subplot(1,2,2)
plot(x, sin(x), 'linewidth', 2, 'DisplayName','sin')
legend('location', 'best')
darkBackground()

tiled

figure();
x = linspace(0,2*pi,100);
tiledlayout(1,2)
nexttile()
plot(x, cos(x), 'linewidth', 2, 'DisplayName','cos')
legend('location', 'best')
nexttile()
plot(x, sin(x), 'linewidth', 2, 'DisplayName','sin')
legend('location', 'best')
darkBackground()

Forgotten

boxplot

https://www.mathworks.com/help/stats/boxplot.html#bu5hny0
figure();
load carsmall
boxplot(MPG)
xlabel('All Vehicles')
ylabel('Miles per Gallon (MPG)')
title('Miles per Gallon for All Vehicles')
darkBackground()

boxchart

https://www.mathworks.com/help/matlab/ref/boxchart.html#mw_0c568666-1784-4d18-a8b9-0e31302241d8
figure();
load patients
b = boxchart(Age);
b.BoxFaceColor = 'r';
ylabel('Age (years)')
darkBackground();

yyaxis right

https://www.mathworks.com/help/matlab/ref/yyaxis.html#bunqz2o-1_1
figure();
x = linspace(0,10,100);
y = sin(3*x);
yyaxis left
plot(x,y, 'linewidth', 2)
z = sin(3*x).*exp(0.5*x);
yyaxis right
plot(x,z, 'linewidth', 2)
ylim([-150 150])
darkBackground();